<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateCommentsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('comments', function (Blueprint $table) {
            $table->id();
            $table->integer('parentId', false, true)->nullable()->comment('父级id');
            $table->integer('userId', false, true)->comment('用户id');
            $table->integer('atUserId', false, true)->nullable()->comment('@用户id');
            $table->integer('questionId', false, true)->comment('题目id');
            $table->text('content')->nullable()->comment('内容');
            $table->integer('like')->default(0)->comment('点赞数量');
            $table->timestamps();
        });

        DB::statement("ALTER TABLE comments comment '评论表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('comments');
    }
}
